<template>
  <view class="index">
    <view class="jtop">
      <view class="status_bar"><!-- 这里是状态栏 --></view>
      <view class="jtop_l" @tap="navigateBack"
        ><image src="../../static/img/ic_back.png"></image
      ></view>
      <view class="jtop_c">项目成员</view>
      <!-- <view class="jtop_r">管理</view> -->
    </view>

    <view class="tophr"></view>

    <view class="ptt" @tap="to_add">
      <image src="../../static/img/index/glcy.png" class="pttl"></image>
      <view class="pttr">
        <view class="pttrt">
          成员角色
        </view>
        <view class="pttrf">
          为成员添加角色，职责更清晰
        </view>
      </view>
      <image src="../../static/img/jt.png" class="pttjt"></image>
    </view>

    <view class="ptf">
      <view class="ptft" @tap="to_add">
        <image src="../../static/img/index/ic_add_1.png"></image>
        <text>添加成员</text>
      </view>

      <view
        class="jhead_portrait"
        @tap="logoTime(item.id)"
        v-for="(item, index) in items"
        :key="item.id"
      >
        <image
          :src="
            item.userInfo.avatar
              ? item.userInfo.avatar
              : '../../static/img/Default_avatar.png'
          "
          class="txl"
        ></image>
        <view class="txc">
          <view class="txct">
            {{ item.userInfo.realName }}
          </view>
          <view class="txcf">
            {{ item.role.name }}
          </view>
        </view>
        <image src="../../static/img/jt.png" class="pttjt"></image>
      </view>

      <!-- 	
			<view class="jhead_portrait"  @tap="logoTime('11111')" >
				<image src="../../static/img/Default_avatar.png" class="txl"></image>
				<view class="txc">
					<view class="txct">
						2343
					</view>
					<view class="txcf">
						项目经理
					</view>
				</view>
				<image src="../../static/img/jt.png"  class="pttjt"></image>
			</view>
			
 -->
    </view>

    <!-- 弹出层 -->
    <view :class="[ashowpop ? 'tc' : 'tc hide']">
      <view class="jtop_bj" @click="jsj"></view>

      <view class="tc_fbox">
        <view class="tc_fbox_bt2" @click="scjs">
          删除用户
        </view>

        <view class="tc_fbox_bt" @click="jsj">
          取消
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import request from '@/common/request.js';
import { mapState } from 'vuex';

export default {
  computed: mapState(['forcedLogin', 'hasLogin', 'userName']),

  data() {
    return {
      repeat_click: true,

      kong: true,
      id: '',
      name: '',
      items: '',
      ashowpop: false,
      jqeditid: '',
    };
  },
  onShow() {
    this.lb();
  },

  onLoad(e) {
    this.id = e.id;
    this.name = e.name;
    this.dsc = e.dsc;
  },
  methods: {
    jsj() {
      this.ashowpop = false;
    },
    scjs() {
      var that = this;
      var cc = that.jqeditid;

      request({
        url: `/ucenter/project-user-role/${cc}`,
        method: 'DELETE',

        success: res => {
          if (res.data.success == true) {
            that.lb();
            that.ashowpop2 = false;
            wx.showToast({
              title: '删除成功',
              icon: 'none',
              duration: 1500,
              success: function() {
                // setTimeout(function() {
                  that.ashowpop = false;
                

                  //   uni.navigateTo({
                  // url: '../user/tream',
                  //   });
                // }, 1500);
              },
            });
          } else {
            // 错误
            that.repeat_click = true;
            uni.showToast({
              title: res.data.msg,
              icon: 'none',
            });
          }
        },
        fail: () => {
          that.repeat_click = true;
          uni.showToast({
            title: '服务器开小差，请稍后~',
            icon: 'none',
          });
          return false;
        },
      });
    },
    logoTime(e) {
      this.jqeditid = e;
      this.ashowpop = true;
    },

    lb() {
      this.projectId = uni.getStorageSync('dqfull_name').id;

      // 获取列表信息
      request({
        url: `/ucenter/project-user-role/${this.projectId}`,
        method: 'GET',

        success: res => {
          console.log('项目列表', res);
          console.log(res.data.data.length);
          if (res.data.success == true) {
            console.log('1111:', res.data.data.length);
            if (res.data.data.length > 0) {
              this.items = res.data.data;
              console.log(this.items);
              this.nodata = false;
            } else {
               this.items = "";
              this.dqfull_name = '';
              this.nodata = true;
            }
          } else {
            this.repeat_click = true;
            uni.showToast({
              title: res.data.msg,
              icon: 'none',
            });
          }
        },
        fail: () => {
          this.repeat_click = true;
          uni.showToast({
            title: '服务器开小差，请稍后~',
            icon: 'none',
          });
          return false;
        },
      });
    },

    to_add() {
      uni.navigateTo({
        url: '../main/project_team_add?id=' + this.id,
      });
    },
    navigateBack() {
      uni.navigateBack();
    },
  },
};
</script>

<style>
.tophr {
  width: 100%;
  height: 88rpx;
}
.ptt {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #ffffff;
  box-shadow: inset 0px 1px 0px #dddddd, inset 0px -1px 0px #dddddd;
  margin: 20rpx 0 0;
}
.pttl {
  width: 84rpx;
  height: 84rpx;
  display: block;
  float: left;
  margin: 18rpx 20rpx 18rpx 30rpx;
}
.pttr {
  width: 400rpx;
  height: 84rpx;
  display: block;
  float: left;
  margin: 18rpx 0rpx 0rpx 0rpx;
}
.pttrt {
  width: 100%;
  height: 42rpx;
  line-height: 42rpx;
  display: block;
  float: left;
  font-size: 34rpx;
  color: #000000;
}
.pttrf {
  width: 100%;
  height: 42rpx;
  line-height: 42rpx;
  display: block;
  float: left;
  font-size: 24rpx;
  color: #999999;
}
.pttjt {
  width: 16rpx;
  height: 25rpx;
  display: block;
  float: right;
  margin: 48rpx 30rpx 0 30rpx;
}
.ptf {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #ffffff;
  border: 1px solid #dddddd;
  border-left: 0;
  border-right: 0;
  margin: 20rpx 0 0;
}
.ptft {
  width: 720rpx;
  margin: 0 0 0 30rpx;
  height: 90rpx;
  display: block;
  float: left;
  background: #ffffff;
  border-bottom: 1px solid #dddddd;
}
.ptft image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
  margin: 21rpx 20rpx 0 0rpx;
}
.ptft text {
  width: auto;
  height: 48rpx;
  display: block;
  float: left;
  margin: 21rpx 20rpx 0 0rpx;
  font-size: 34rpx;
  line-height: 48rpx;
  color: #000000;
}
.jhead_portrait {
  width: 720rpx;
  height: 120rpx;
  display: block;
  float: right;
  margin: 0rpx;
  border-bottom: 1px solid #dddddd;
}
.txl {
  width: 84rpx;
  height: 84rpx;
  display: block;
  float: left;
  margin: 18rpx 20rpx 18rpx 0rpx;
  border-radius: 6rpx;
}
.pttjt {
  width: 16rpx;
  height: 25rpx;
  display: block;
  float: right;
  margin: 48rpx 30rpx 0 30rpx;
}
.txc {
  width: 400rpx;
  height: auto;
  display: block;
  float: left;
  margin: 0;
}
.txct {
  width: 100%;
  height: 42rpx;
  line-height: 42rpx;
  display: block;
  float: left;
  font-size: 34rpx;
  color: #000000;
  margin: 18rpx 0 0 0;
}
.txcf {
  width: 100%;
  height: 32rpx;
  line-height: 32rpx;
  display: block;
  float: left;
  font-size: 24rpx;
  color: #999999;
  margin: 10rpx 0 0 0;
}

.addi input {
  width: 580rpx;
  height: 50rpx;
  display: block;
  float: left;
  margin: 24rpx 30rpx 24rpx 30rpx;
  text-align: left;
  line-height: 50rpx;
  font-size: 34rpx;
  color: #000000;
}
.addi image {
  width: 36rpx;
  height: 36rpx;
  display: block;
  float: right;
  margin: 30rpx 20rpx 0 0rpx;
}

.addb {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #ffffff;
  margin: 20rpx 0 0;
}
.addbi {
  width: 720rpx;
  margin: 0 0 0 30rpx;
  height: 90rpx;
  display: block;
  float: left;
  background: #ffffff;
  border-bottom: 1px solid #dddddd;
}
.addb .addbi:last-child {
  border: none;
}
.addbi .addbil {
  width: auto;
  height: 90rpx;
  display: block;
  float: left;
  line-height: 90rpx;
  font-size: 34rpx;
  color: #000000;
}
.addbi .addbir {
  width: auto;
  height: 90rpx;
  display: block;
  float: right;
  line-height: 90rpx;
  font-size: 32rpx;
  color: #999999;
}
.addbi image {
  width: 16rpx;
  height: 25rpx;
  display: block;
  float: right;
  margin: 33rpx 30rpx 0 30rpx;
}
.addi textarea {
  width: 690rpx;
  height: 150rpx;
  display: block;
  float: left;
  margin: 0rpx 30rpx 20rpx;
  text-align: left;
  line-height: 40rpx;
  font-size: 34rpx;
  color: #999999;
}

.index {
  background: rgb(242, 242, 242);
  width: 100%;
  height: auto;
}
.jtop {
  width: 100%;
  height: 88rpx;
  background: #ffffff;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  box-shadow: inset 0px -1px 0px #dddddd;
}
.jtop_l {
  width: auto;
  height: 88rpx;
  display: block;
  float: left;
  font-size: 32rpx;
  color: #000000;
  line-height: 88rpx;
  margin: 0 0 0 30rpx;
}
.jtop_l image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
  margin: 20rpx 0 20rpx 0;
}
.jtop_r {
  width: auto;
  height: 88rpx;
  display: block;
  float: right;
  margin: 0rpx 20rpx 0 0;
  line-height: 88rpx;
  font-size: 32rpx;
  color: #000000;
}
.jtop_r image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
}
.jtop_c {
  width: 70%;
  height: 48rpx;
  line-height: 48rpx;
  display: block;
  float: left;
  position: fixed;
  top: 20rpx;
  left: 15%;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
}
.jtop_c image {
  width: 36rpx;
  height: 36rpx;
  display: inline-block;
  float: none;
  margin-bottom: -5rpx;
  margin-left: 5rpx;
}
.jtop_b {
  width: 100%;
  height: auto;
  background: #ffffff;
  position: fixed;
  top: 88rpx;
  left: 0;
  z-index: 1001;
}
.jtop_bj {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999;
}

.jtop_bs {
  width: 100%;
  height: auto;
  background: #ffffff;
  display: block;
  float: left;
}
.jtop_bs view {
  width: 720rpx;
  height: 90rpx;
  background: #ffffff;
  display: block;
  float: left;
  margin: 0 0 0 30rpx;
  border-bottom: 1px solid #dddddd;
}
.jtop_bs view text {
  width: 80%;
  height: 90rpx;
  line-height: 90rpx;
  background: #ffffff;
  display: block;
  float: left;
  font-size: 34rpx;
  color: #000000;
}
.jtop_bs view image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: right;
  margin: 21rpx 30rpx 0 0;
}
.jtop_tc {
  display: none;
}

.tc {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9;
}
.jtop_bj {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
}
.tc_box {
  width: 540rpx;
  height: 400rpx;
  background: #ffffff;
  border-radius: 14rpx;
  margin: 460rpx 105rpx 0;
  position: relative;
  z-index: 10001;
  overflow: hidden;
}
.tc_boxt {
  width: 100%;
  height: 44rpx;
  font-size: 36rpx;
  line-height: 44rpx;
  display: block;
  float: left;
  text-align: center;
  margin: 40rpx 0 20rpx;
  color: #000000;
}
.tc_boxtc {
  width: 100%;
  height: 36rpx;
  font-size: 28rpx;
  line-height: 36rpx;
  display: block;
  float: left;
  text-align: center;
  margin: 0rpx 0 30rpx;
  color: #666666;
}
.tc_boxi {
  width: 460rpx;
  height: 88rpx;
  background: #ffffff;
  border-radius: 8rpx;
  border: 1px solid #dddddd;
  display: block;
  float: left;
  margin: 0rpx 40rpx 42rpx 40rpx;
}
.tc_boxi input {
  width: 90%;
  height: 48rpx;
  margin: 20rpx 5%;
  font-size: 32rpx;
  color: #000000;
}
.tc_f {
  width: 100%;
  height: 100rpx;
  display: block;
  float: left;
  border-top: 1px solid #dcdee3;
}
.tc_fl {
  width: 269rpx;
  height: 100rpx;
  line-height: 100rpx;
  text-align: center;
  font-size: 36rpx;
  color: #256aff;
  display: block;
  float: left;
  border-right: 1px solid #dcdee3;
}
.tc_fr {
  width: 269rpx;
  height: 100rpx;
  line-height: 100rpx;
  text-align: center;
  font-size: 36rpx;
  color: #256aff;
  display: block;
  float: left;
}
.tc_fr.no {
  opacity: 0.5;
}

.tc_fbox_bt {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
  border-top: 20rpx solid #f2f2f2;
  background: #ffffff;
}
.tc_fbox {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #f2f2f2;
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 10001;
}
.tc_fbox_bt2 {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  text-align: center;
  font-size: 36rpx;
  color: red;
  border-top: 0rpx solid #f2f2f2;
  background: #ffffff;
}
</style>
